package io;

import java.io.*;

public class CopyDemo2 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("image.png");
        FileOutputStream fos = new FileOutputStream("image_cp2.png");
        long len;
        byte[] buf = new byte[1024*10];
        long stats = System.currentTimeMillis();
        while ((len = fis.read(buf)) != -1){
            fos.write(buf,0, (int) len);
        }
        long end = System.currentTimeMillis();
        System.out.println("执行完毕，一共耗时：" + (end - stats) + "ms");
        fos.close();
        fis.close();


        FileInputStream fis1 = new FileInputStream("./image.png");
        FileOutputStream fos1 = new FileOutputStream("./image_cp2.png");
        int len1;
        long stats1 = System.currentTimeMillis();
        byte[] buf1 = new byte[1024*10];
        while ((len1 = fis1.read(buf1)) != -1){
            fos1.write(buf1,1,len1);
        }
        long end1 = System.currentTimeMillis();
        System.out.println("执行完毕,一共耗时：" + (end1 - stats1));
        fos1.close();
        fis1.close();
    }
}
